package com.hk.webapp.service.impl;

import com.hk.webapp.bean.SysUser;
import com.hk.webapp.dao.SysUserMapper;
import com.hk.webapp.vo.PageVo;
import com.hk.webapp.service.SysUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly = true)
public class SysUserServiceImpl implements SysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    @Override
    public SysUser getEntityById(Integer id) {
        return sysUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int getCount() {
        return sysUserMapper.getCount();
    }

    @Override
    @Transactional
    public int updateSysUser(SysUser sysUser) {
        return sysUserMapper.updateSysUser(sysUser);
    }

    @Override
    @Transactional
    public int resetPasswd(SysUser sysUser) {
        return sysUserMapper.resetPasswd(sysUser);
    }

    @Override
    public PageInfo<SysUser> getPageList(PageVo vo) {
        PageHelper.startPage(vo.getPageIndex(),vo.getPageSize());
        List<SysUser> list=sysUserMapper.getPageList();
        PageInfo<SysUser> plist=new PageInfo<>(list);
        return plist;
    }

    @Override
    @Transactional
    public int changeLock(SysUser sysUser) {
        return sysUserMapper.changeLock(sysUser);
    }

    @Override
    @Transactional
    public int insert(SysUser sysUser) {
        return sysUserMapper.insertSelective(sysUser);
    }

    @Override
    @Transactional
    public int deleteByIds(List<Integer> ids) {
        return sysUserMapper.deleteByIds(ids);
    }

    @Override
    public List<SysUser> getEntityByIds(List<Integer> ids) {
        return sysUserMapper.getEntityByIds(ids);
    }
}
